import java.util.Scanner;

/**
 * Created by L.jp
 * Description:
 * User: 86189
 * Date: 2021-10-07
 * Time: 21:28
 */
public class ReturnOperation implements Ioperation {
    @Override
    public void work(BookList bookList) {
        Scanner reader = new Scanner(System.in);
        String name;
        System.out.print("请输入你要归还的书名：");
        name = reader.nextLine();
        for (int i = 0; i < bookList.getSize(); i++) {
            if (name.equals(bookList.getBook(i).getName())) {
                if (bookList.getBook(i).isLent() == true) {
                    bookList.getBook(i).setLent(false);
                    System.out.println("该书归还成功");
                    return;
                } else {
                    System.out.println("该书未被借阅，操作错误");
                    return;
                }
            }
        }
        System.out.println("未查询到你要归还的书籍，操作错误");
    }
}

